#include <iostream>
using namespace std;

const int N = 1e5 + 10;
int n;
int f[N], g[N];
int p[N];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> p[i];


    g[0] = -p[0];
    for (int i = 1; i <= n; i++)
    {
        f[i] = max(f[i - 1], g[i - 1] + p[i]);
        g[i] = max(g[i - 1], f[i - 1] - p[i]);
    }

    cout << max(f[n - 1], g[n - 1]);

    return 0;
}
